package com.gewu.pm.ui.adapter.home;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.gewu.pm.R;
import com.gewu.pm.app.AppAdapter;
import com.gewu.pm.bean.TestBean;

/**
 * 销售单据列表适配器
 */
public class SalesStatementAdapter extends AppAdapter<TestBean> {

    public SalesStatementAdapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ItemViewHolder();
    }

    private final class ItemViewHolder extends AppAdapter<?>.ViewHolder {

        private final TextView mTitleView;
        private final TextView mDeliveryDateView;
        private final TextView mDeliveryNoView;
        private final TextView mDeliveryAmountView;
        private final TextView mSettledAmountView;
        private final TextView mPendingAmountView;

        private ItemViewHolder() {
            super(R.layout.sales_statement_item);
            mTitleView = findViewById(R.id.tv_title);
            mDeliveryDateView = findViewById(R.id.tv_delivery_date);
            mDeliveryNoView = findViewById(R.id.tv_delivery_no);
            mDeliveryAmountView = findViewById(R.id.tv_delivery_amount);
            mSettledAmountView = findViewById(R.id.tv_settled_amount);
            mPendingAmountView = findViewById(R.id.tv_pending_amount);

        }

        @Override
        public void onBindView(int position) {
            TestBean item = getItem(position);
            
            // 设置客户名称
            mTitleView.setText(item.getName());
            
            // 固定写死的内容
            mDeliveryDateView.setText("2025-01-01");
            mDeliveryNoView.setText("FH202509021165");
            mDeliveryAmountView.setText("¥25.00");
            mSettledAmountView.setText("¥275.00");
            mPendingAmountView.setText("¥275.00");
        }
    }
}
